package main;

import org.apache.log4j.Logger;
import org.junit.jupiter.api.Test;
import proxy.IntermediaryCglibProxyFactory;
import proxy.IntermediaryJdkProxyFactory;
import proxy.IntermediarySubclass;
import service.Buyer;
import service.impl.RealBuyer;

public class IntermediarySubclassTest {
    private Logger logger = Logger.getLogger(IntermediarySubclassTest.class);
//    RealBuyer buyer = new IntermediarySubclass();
//    String result = buyer.havealook();
//    logger.debug(result);
    @Test
    public void havealookJdkProxy() throws Exception{
        Buyer buyer = IntermediaryJdkProxyFactory.create(new RealBuyer());
        String result = buyer.havealook();
        logger.debug(result);
    }
    @Test
    public void havealookCglibProxy() throws Exception{
        RealBuyer buyer = IntermediaryCglibProxyFactory.create(RealBuyer.class);
        String result = buyer.havealook();
        logger.debug(result);
    }
}
